package flc.ast.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;

import android.os.Bundle;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;

import java.util.ArrayList;
import java.util.List;

import flc.ast.BaseAc;
import flc.ast.R;
import flc.ast.adapter.InstructionAdapter;
import flc.ast.bean.MyInstructionBean;
import flc.ast.databinding.ActivityInstructionBinding;
import stark.common.basic.event.EventStatProxy;

public class InstructionActivity extends BaseAc<ActivityInstructionBinding> {

    private List<MyInstructionBean> listInstruction=new ArrayList<>();
    private InstructionAdapter instructionAdapter;

    @Override
    protected int onCreate() {
        return R.layout.activity_instruction;
    }

    @Override
    protected void initView() {
        EventStatProxy.getInstance().statEvent1(this, mDataBinding.event1Container);
        mDataBinding.ivInstructionBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        mDataBinding.rvInstructionList.setLayoutManager(new LinearLayoutManager(mContext,LinearLayoutManager.VERTICAL,false));
        instructionAdapter=new InstructionAdapter();
        mDataBinding.rvInstructionList.setAdapter(instructionAdapter);
        instructionAdapter.setOnItemClickListener(this);
    }

    @Override
    protected void onItemClickCallback(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
        if (position!=listInstruction.size()-1){
            InstDetailActivity.city=instructionAdapter.getItem(position).getCity();
            startActivity(InstDetailActivity.class);
        }
    }

    @Override
    protected void initData() {
        listInstruction.clear();
        listInstruction.add(new MyInstructionBean(getString(R.string.city_bj),R.drawable.beijing1,getString(R.string.instruction_desc)));
        listInstruction.add(new MyInstructionBean(getString(R.string.city_sh),R.drawable.shanghai1,getString(R.string.instruction_desc)));
        listInstruction.add(new MyInstructionBean(getString(R.string.city_gz),R.drawable.guangzhou1,getString(R.string.instruction_desc)));
        listInstruction.add(new MyInstructionBean(getString(R.string.city_sz),R.drawable.shenzhen1,getString(R.string.instruction_desc)));
        listInstruction.add(new MyInstructionBean(getString(R.string.city_more),R.drawable.gengduocs1,getString(R.string.instruction_update)));
        instructionAdapter.setList(listInstruction);
    }
}